﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_UPDMS_Get_Code_View_Order')
	BEGIN
		DROP Function ufn_UPDMS_Get_Code_View_Order
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : ufn_UPDMS_Get_Code_View_Order
**	Desc : 공통코드의 조회순서를 가져온다.
**	Test Exec Query : Exec ufn_UPDMS_Get_Code_View_Order 'AC001', 'CRD'
**	Called by : 전체
**	Program ID : 전체
**	Auth : 송시명
**	Date : 2010-10-18
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE FUNCTION [dbo].[ufn_UPDMS_Get_Code_View_Order]
(
@ls_cd nvarchar(5),
@ls_id nvarchar(3)
)
RETURNS nvarchar(200)
AS

BEGIN
    DECLARE @rtn nvarchar(200)
    SET @rtn = ''

    SELECT @rtn = View_Order
      FROM (
           SELECT View_Order
             FROM UPDMS_COM_CD WITH(NOLOCK)
            WHERE Cd = @ls_cd
              AND Id = @ls_id
              AND Use_Yn = 'Y'
           ) rslt
  
    RETURN LTRIM(RTRIM(@rtn))
  
END